﻿using Com.Lancetinc.Evs.Resources;
using System;
using System.Windows;
using System.Windows.Data;

namespace Com.Lancetinc.Evs.WpfTools
{
    [ValueConversion(typeof(bool), typeof(Visibility))]
    public sealed class StringToImageSourceConverter : IValueConverter
    {
        public object Convert(object value, Type targetType,
            object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return null;

            var path = value.ToString();
            return ResourceHelper.GetImageFromFile(path);

        }

        public object ConvertBack(object value, Type targetType,
            object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException("Not implemented.");
        }
    }
}
